<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/dialogLayout.xhtml">  
	<ui:param name="param_pageTitle" value="#{messages.crud_btn_add}" />
    <ui:param name="param_panelWidth" value="600px"/>	
    <ui:param name="id" value="user" />
	<ui:define name="content">
      <ui:decorate template="/components/formTemplate.xhtml">
            <ui:param name="id" value="userForm"/>
            <ui:param name="param_headerTitle" value="新建会员" />
            <ui:define name="fields">
					<rg:inputText id="mobile"  required="true"  label="#{messages.luyuan_member_mobile}" 
						value="#{customerAction.customer.mobile}" validator="#{customerMoblieValidator}" tip="即为会员号。"/>
					<rg:inputText id="name" required="true" label="#{messages.luyuan_member_name}" value="#{customerAction.customer.name}"  />
					<rg:selectOne id="gender"  required="true"  label="姓别" value="#{customerAction.customer.gender}" 
	                    converter="#{genderConverter}" itemsProvider="#{genderProvider}"/>
					<rg:field label="生日">
                    	<rg:datetime value="#{customerAction.customer.birthDate}" datePattern="yyyy-MM-dd" />
                    </rg:field>
					<rg:inputText id="qq" label="QQ" value="#{customerAction.customer.qq}" />
					<rg:inputText id="email" label="#{messages.luyuan_member_email}" value="#{customerAction.customer.email}" />
					<rg:field id="reference" label="介绍人" tip="请输入姓名或者手机号" >
						<h:inputText id="reference" value="#{customerAction.customer.reference}" converter="#{customerMoblieConverter}" styleClass="text" >
							<a:support event="onblur" reRender="reference_name" ajaxSingle="true" eventsQueue="reference"/>
						</h:inputText>
						<h:outputText id="reference_name" value="#{customerAction.customer.reference.name}"  />
					</rg:field>
					<rg:inputText id="nativePlace" label="籍贯" value="#{customerAction.customer.nativePlace}"/>
                    <rg:field id="address" label="#{messages.luyuan_member_addresses}">
                    	<h:selectOneMenu id="province" value="#{customerAction.customer.address.province}" styleClass="select" 
                    		onchange="jQuery('#userForm\\:city').val(null);jQuery('#userForm\\:region').val(null);">
                    		<f:selectItem itemLabel="请选择省"/>
                    		<f:selectItems value="#{provinceProvider.getSelectItems(null)}" eventsQueue="address"/>
                    	</h:selectOneMenu>
                    	<h:selectOneMenu id="city" value="#{customerAction.customer.address.city}"   styleClass="select" 
                    		onchange="jQuery('#userForm\\:region').val(null);">
                    		<f:selectItem itemLabel="请选择市"/>
                    		<f:selectItems value="#{cityProvider.getSelectItems(customerAction.customer.address.province)}" />
                    		<rg:reference for="province" eventsQueue="address"/>
                    	</h:selectOneMenu>
                    	<h:selectOneMenu id="region" value="#{customerAction.customer.address.region}" styleClass="select"  >
                    		<f:selectItem itemLabel="请选择区（县）"/>
                    		<f:selectItems value="#{regionProvider.getSelectItems(customerAction.customer.address.province,customerAction.customer.address.city)}" />
                    		<rg:reference for="province,city" eventsQueue="address"/>
                    	</h:selectOneMenu>
                    </rg:field>
                    <rg:inputText id="street" value="#{customerAction.customer.address.street}" textStyle="width:200px;"/>
					<rg:inputText id="postCode" label="#{messages.luyuan_member_postCode}" value="#{customerAction.customer.address.postCode}" >
						<rg:reference for="city,region" actionListener="#{customerAction.resetPostCode}" eventsQueue="address"/>
					</rg:inputText>
					<rich:suggestionbox id="suggestionBoxId" for="reference" tokens=",[]"
	                    suggestionAction="#{customerMoblieProvider.getSuggestionItems}" var="result"
	                    fetchValue="#{result.mobile}" 
	                    minChars="1"   eventsQueue="customer"
	                    nothingLabel="无此客户信息" columnClasses="center"
	                    usingSuggestObjects="true">
	                    <h:column>
	                        <h:outputText value="#{result.name}" />
	                    </h:column>
	                    <h:column>
	                        <h:outputText value="#{result.mobile}" />
	                    </h:column>
                	</rich:suggestionbox>
			</ui:define>
			<ui:define name="panelButton">
                <a:commandButton styleClass="button"
                    value="#{messages.btn_complete}" onclick="UI.instance.showMask();"
                    oncomplete="UI.instance.reRender('reRenderMemberTable');UI.instance.hideMask();"
                    action="#{customerAction.add()}"
                    reRender="globalMessage" />
                <input type="button" class="button" value="#{messages.btn_cancel}"
                    onclick="javascript:DialogLayout.instance.close();" />
            </ui:define>
			</ui:decorate>
	</ui:define>
</ui:composition>